package com.bdqn.appjob.controller;

import java.util.List;

import javax.annotation.Resource;

import com.bdqn.appjob.service.backend.BackAppCategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;

import com.bdqn.appjob.entity.AppCategory;
import com.bdqn.appjob.service.backend.BackAppCategoryService;

@Controller
@RequestMapping(value="/manager/backend/app")
public class AppCategoryController {
	@Resource
	private BackAppCategoryService appCategroyService;
	
	//加载二级分类
		@RequestMapping(value="/categorylevellist.json", method=RequestMethod.GET,produces={"application/json;charset=UTF-8"})
		@ResponseBody
		public Object queryCategoryLevel1(@RequestParam String pid){
			System.out.println("进来了pid="+pid);
			List<AppCategory> data = null;
			try {
				if(pid != null && pid != ""){
					data = appCategroyService.getListId(Integer.parseInt(pid));
				}else{
					data = appCategroyService.getListId(null);
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			for(AppCategory a:data){
				System.out.println("=================="+a.getCategoryName());
			}
			return JSONArray.toJSONString(data);
		}

}
